home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / pixrect / bitmap.h next >
Encoding:
C/C++ Source or Header  |  1989-03-17  |  3.2 KB  |  107 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: bitmap.h,v 4.3 88/07/19 14:20:06 sau Exp $
  9.     $Source: /tmp/mgrsrc/src/pixrect/RCS/bitmap.h,v $
  10. */
  11. static char    h_sundep_[] = "$Source: /tmp/mgrsrc/src/pixrect/RCS/bitmap.h,v $$Revision: 4.3 $";
  12.  
  13. /* map generic bit-blit library calls to sun pixrect */
  14.  
  15. #include <sys/types.h>
  16. #include <pixrect/pixrect_hs.h>
  17.  
  18. #define GT0(x)    ((x)>0?(x):0)    /* SUN's routines don't always clip */
  19. #define GET_OP(x)    ((x)<<1)
  20.  
  21. #define bit_blit(dst,dx,dy,wide,high,f,src,sx,sy) \
  22.     pr_rop(dst,dx,dy,wide,high,f,src,sx,sy)
  23.  
  24. #define bit_line(map,x1,y1,x2,y2,op) \
  25.     pr_vector(map,GT0(x1),GT0(y1),GT0(x2),GT0(y2),op,0)
  26.  
  27. #define bit_create(map,x,y,wide,high) \
  28.     pr_region(map,x,y,wide,high)
  29.  
  30. #define bit_alloc(wide,high,data,depth) \
  31.         (data==0 ? mem_create(wide,high,depth) : \
  32.          mem_point(wide,high,depth,data))
  33.  
  34. #define bit_destroy(map) \
  35.     pr_destroy(map)
  36.  
  37. #define bit_open(dev) \
  38.     pr_open(dev)
  39.  
  40. #define bit_pattern    pr_replrop  /* aarg */
  41.  
  42. #define BIT_NOT(x) \
  43.     PIX_NOT(x)
  44.  
  45. #define bit_static(name,wide,high,data,depth) \
  46.     mpr_static(name,wide,high,depth,data)
  47.  
  48. #define BITMAP        struct pixrect
  49. #define BIT_NULL        ((BITMAP *) 0)
  50. #define NULL_DATA    ((unsigned short *) 0)
  51.  
  52. #define BIT_WIDE(b)    b->pr_size.x
  53. #define BIT_HIGH(b)    b->pr_size.y
  54.  
  55. #define BIT_X(b) \
  56.     (((struct mpr_data *) ((b)->pr_data))->md_offset.x)
  57.  
  58. #define BIT_Y(b) \
  59.     (((struct mpr_data *) ((b)->pr_data))->md_offset.y)
  60.  
  61. #define BIT_DATA(b) \
  62.     ((char *) (((struct mpr_data *) ((b)->pr_data))->md_image))
  63.  
  64. #define BIT_DEPTH(b) b->pr_depth
  65.  
  66. #define BIT_SIZE(m)    (BIT_DEPTH(m)==1 ? \
  67.             (((BIT_WIDE(m)+15L)&~15)*BIT_HIGH(m)>>3) : \
  68.             BIT_WIDE(m)*BIT_HIGH(m)*(BIT_DEPTH(m)>>3))
  69.  
  70. #define OPCODE(x)        (x)        /* this is probably wrong */
  71.  
  72. #define BIT_CLR        PIX_CLR
  73. #define BIT_SET        PIX_SET
  74. #define BIT_SRC        PIX_SRC
  75. #define BIT_DST        PIX_DST
  76.  
  77. int bit_point();    /* sun doesn't have a point routine */
  78.  
  79. #ifdef COLOR
  80. #define DEPTH                8                /* bits per pixel */
  81. #define BITS                7                /* row padding for bitmaps */
  82. #define NOCOLOR         0x1F
  83. #define GETCOLOR(x)     ((x)<<5)
  84. #define PUTCOLOR(x)     ((x)>>5)
  85. /* the internal alignment of monochrome bitmaps seems to have changed from
  86.    16 to 32 bits on OS 4.0 when using the color frame buffer, although 
  87.     alignment using mpr_static() is still 16 bits
  88.  */
  89. #ifdef pixrect_hs_DEFINED        /* defined only on OS >= 4.0 */
  90. # define BIT_Size(w,h,d)    (d==1 ? (((w+31)&~31)*h>>3) : w*h*d>>3)
  91. #else
  92. # define BIT_Size(w,h,d)    (d==1 ? (((w+15L)&~15)*h>>3) : w*h*d>>3)
  93. #endif
  94.  
  95. #define ROP_INVERT(x)   \
  96.    ((255-(255&(x>>5)))<<5) | (x)&NOCOLOR
  97. #else
  98. #define DEPTH                1                /* bits per pixel */
  99. #define BITS                15                /* row padding for bitmaps */
  100. #define NOCOLOR         0x1F
  101. #define GETCOLOR(x)     (0)
  102. #define PUTCOLOR(x)     (0)
  103. #define BIT_Size(wide,high,d)     (((wide+BITS)&~BITS)*high>>3) /* bytes */
  104. #define ROP_INVERT(x)   \
  105.    ((x)&~0x1E | GET_OP(rev_ops[((x)>>1)&0xF]))
  106. #endif
  107.